package com.quectel.core.module.schedulingapply.dto.vo;


import com.quectel.constant.core.scheduling.SchedulingLeaveConstants;
import com.quectel.core.module.scheduling.dto.SchedulingLeaveBalanceDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/7/12 10:21
 * @description new java file header...
 */
@Data
@Schema
public class SchedulingBalanceTimeVO {
    @Schema(description = "余额id")
    private Long balanceId;
    @Schema(description = "余额")
    private BigDecimal restBalance;
    @Schema(description = "扣减数量")
    private BigDecimal appliedBalance;
    @Schema(description = "单位字典值:SchedulingLeaveTimeUnit")
    private Byte unit;
    @Schema(description = "假期余额对象")
    private SchedulingLeaveBalanceDto schedulingLeaveBalance;
    public BigDecimal getRestBalanceMills() {
        if (unit != null && restBalance != null) {
            SchedulingLeaveConstants.TimeUnitEnum byUnit = SchedulingLeaveConstants.TimeUnitEnum.getByUnit(unit);
            if (byUnit == null) {
                return null;
            }
            return restBalance.multiply(BigDecimal.valueOf(byUnit.getMillis()));
        }
        return null;
    }

    public BigDecimal getAppliedBalanceMills() {
        if (unit != null && appliedBalance != null) {
            SchedulingLeaveConstants.TimeUnitEnum byUnit = SchedulingLeaveConstants.TimeUnitEnum.getByUnit(unit);
            if (byUnit == null) {
                return null;
            }
            return appliedBalance.multiply(BigDecimal.valueOf(byUnit.getMillis()));
        }
        return null;
    }
}
